<template>
  <el-input v-model="title" placeholder="请输入标题" @keydown.enter="addItem"></el-input>
</template>

<script lang="ts">
import { defineComponent, ref } from "vue";
export default defineComponent({
  name: "add",
  props: {
    addL: {
      type: Function,
      required: true
    }
  },
  setup(props) {
    const title = ref("");
    const addItem = () => {
      if (title.value.trim()) {
        let obj = {
          id: Date.now(),
          title: title.value,
          isCheck: false
        };
        props.addL(obj);
        title.value = "";
      }
    };
    return {
      addItem,
      title
    };
  }
});
</script>

<style lang="less" scoped>
</style>
